//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.IO;

namespace OpenLS.Spreadsheet
{
    class AutoRecoverManager
    {
        public static void SaveAutoRecoverInfo (SpreadsheetDocument doc)
        {
            try
            {
                string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                path = Path.Combine(path, "Spreadsheet");
                if (!Directory.Exists(path))
                    Directory.CreateDirectory(path);
                string fileName = Path.Combine(path, doc.Name + "." + doc.Guid.ToString().Replace("-", "") + "." + Guid.NewGuid().ToString().Replace("-", "") + ".xlsx");
                string oldPath = doc.FileName;
                doc.SaveAs(fileName);
                doc.FileName = oldPath;
            }
            catch (Exception)
            { }
        }
    }
}
